package project.product.web;

import java.io.IOException;

import kernel.web.Page;
import kernel.web.PageActionSupport;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import project.order.OrderTemp;
import project.order.OrderTempService;
import project.order.work.WxOpenIdHelper;
import project.product.Brand;
import project.product.BrandService;
import project.vip.services.AdminAdService;

public class BrandAction extends PageActionSupport {

    private static final long serialVersionUID = 4124979461591260805L;

    private static final Log logger = LogFactory.getLog(BrandAction.class);

    private String brand_id;

    private BrandService brandService;
    
    private OrderTempService orderTempService;
    
    private AdminAdService adminAdService;
    private String redirect_url;
    
    protected Page pageAd;
    
    
    public String view() {
        page = Page.EMPTY_PAGE;
        page.setElements(brandService.getAll());
        super.page = page;
        this.tabs = this.bulidTabs();
        
        pageAd = new Page();
        pageAd.setElements(adminAdService.getAll());
        return "view";
    }
    

    public String go() throws IOException {
        Brand brand = brandService.getBrand(brand_id);
        if (brand == null) {
            view();   
            return "view";
        }
//        if (!brand.getSingle()) {
//            return "step2";
//        }else{
//            OrderTemp temp = new OrderTemp();
//            temp.setBrand(brand_id);
//
//            orderTempService.save(temp);
//
//            redirect_url = WxOpenIdHelper.getSingleCodeUrl(temp.getId().toString());
//            
//            return "order";  
//        }
        return "step2";//非单品 单品 都直接到布料列表
    }

    public void setBrandService(BrandService brandService) {
        this.brandService = brandService;
    }

    public String getBrand_id() {
        return brand_id;
    }

    public void setBrand_id(String brand_id) {
        this.brand_id = brand_id;
    }


    public void setOrderTempService(OrderTempService orderTempService) {
        this.orderTempService = orderTempService;
    }


    public String getRedirect_url() {
        return redirect_url;
    }


    public void setRedirect_url(String redirect_url) {
        this.redirect_url = redirect_url;
    }


	/**
	 * @param adminAdService the adminAdService to set
	 */
	public void setAdminAdService(AdminAdService adminAdService) {
		this.adminAdService = adminAdService;
	}


	/**
	 * @return the pageAd
	 */
	public Page getPageAd() {
		return pageAd;
	}


	/**
	 * @param pageAd the pageAd to set
	 */
	public void setPageAd(Page pageAd) {
		this.pageAd = pageAd;
	}
    
    

}
